Repository navigation
fix: use techmo-asr-api stubs instead of generating them at build time - #2
Merged
Merged
Conversation
The hatch build hook generated *_pb2.py from proto/ with whatever grpcio-tools version the build environment resolved (no upper bound). In an isolated build that is the newest grpcio-tools, whose protobuf gencode can be newer than the protobuf runtime the agent environment is constrained to (e.g. livekit-agents 1.5.1 -> opentelemetry-proto <7 -> protobuf 6.x), so `import livekit.plugins.techmo` failed with VersionError on fresh installs. Take the stubs from techmo-asr-api 1.1.4 (asr_api.v1p1), which ships them pre-generated with protobuf 5.29 and works with protobuf 5.29-7.x. Its asr.proto contract is identical to the removed proto/ copy (messages, fields, numbers, types, enums, rpc compared). - remove hatch_build.py, proto/, _proto/ and the grpcio-tools build dependency; --no-build-isolation is no longer needed - depend on techmo-asr-api by git URL (not on PyPI yet) and require protobuf>=5.29.0; cap livekit-agents <2.0 - CI, Makefile, .gitignore, README, CHANGELOG updated Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- techmo-asr-api 1.1.4 stubs embed GRPC_GENERATED_VERSION 1.70.0; with grpcio 1.69 `from asr_api import v1p1` raises RuntimeError, so the >=1.63.0 floor allowed broken installs - README listed livekit-agents >= 1.5 and grpcio >= 1.63, disagreeing with the package metadata (>=1.0,<2.0) and the stubs (>=1.70) - CI triggered on `main`, but the default branch is `master`, so it never ran for pull requests Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Enabling CI on master exposed problems already present on master: - STT.recognize() raised TypeError: livekit-agents calls _recognize_impl(..., conn_options=...), which the plugin did not accept; a single AudioFrame buffer was also not iterable. Covered by a new test through the public recognize() API. - Empty livekit/__init__.py and livekit/plugins/__init__.py made `livekit` a regular package, so with an editable install it shadowed livekit.agents and 2 unit tests failed. Removed (implicit namespace package, like the official livekit plugins); the wheel is unaffected. - mypy pinned python_version 3.10 and aborted on numpy stubs using 3.12 syntax; the pin is dropped and the type errors it then reported are fixed (LanguageCode in livekit-agents >=1.8 is ignored per line since older 1.x lacks it). - ruff check --fix and ruff format; isort told that livekit.plugins.techmo is first-party within the shared livekit namespace. Verified on Python 3.10 in a clean venv with livekit-agents 1.8.8 and 1.5.1: ruff, ruff format --check, mypy and 19 unit tests pass. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The batch recognize fix (conn_options argument, single AudioFrame buffer) goes to a separate PR. Until then the two mypy errors it fixes are silenced in _recognize_impl, so CI stays green. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Installing the plugin fresh can produce a package that fails on import:
The hatch build hook generates
*_pb2.pyfromproto/using whatevergrpcio-toolsthe build environment resolves (no upper bound). In an isolated build (the default forpip install) that is the newestgrpcio-tools, whose protobuf gencode can be newer than the protobuf runtime the agent environment is constrained to. Withlivekit-agents==1.5.1,opentelemetry-protocaps protobuf at<7, so the stubs no longer import.Reproduced on current
master(0.2.0): a fresh install withlivekit-agents==1.5.1fails with the error above.Change
Stubs from
techmo-asr-apiStubs now come from
techmo-asr-api1.1.4 (asr_api.v1p1), the same package the internal plugin uses. It ships them pre-generated with protobuf 5.29, so nothing is generated at install time.hatch_build.py,proto/,livekit/plugins/techmo/_proto/and thegrpcio-toolsbuild dependency;--no-build-isolationis no longer neededstt.py:from asr_api import v1p1 as _proto. The alias name is kept, so the rest of the module is unchangedtechmo-asr-api @ git+…@1.1.4(not on PyPI yet, henceallow-direct-references),protobuf>=5.29.0andgrpcio>=1.70.0(the stubs need a runtime ≥ gencode; they embedGRPC_GENERATED_VERSION = '1.70.0'),livekit-agents>=1.0,<2.0livekit-agents >= 1.5,grpcio >= 1.63)CI now actually runs
CI triggered on
main, while the default branch ismaster, so it never ran on PRs. It now triggers onmaster. Enabling it exposed problems already present onmaster, fixed here so the pipeline is green:livekit/__init__.pyandlivekit/plugins/__init__.py. They madelivekita regular package, so an editable install (pip install -e ., as in CI) shadowedlivekit.agentsand 2 unit tests failed.livekitis now an implicit namespace package, like in the official LiveKit plugins; the wheel contents are unchangedpython_version = "3.10"pin (mypy aborted on numpy stubs using 3.12 syntax) and fixed the type errors it then reported.LanguageCode(livekit-agents ≥ 1.8 only) is ignored per linecheck --fixandformat(unused imports, import order, formatting); isort configured to treatlivekit.plugins.techmoas first-party inside the sharedlivekitnamespacemypy also flags
_recognize_impl(override,union-attr). That is a real bug:STT.recognize()raisesTypeErroronconn_options. It is silenced withtype: ignorehere and fixed in #3 (stacked on this PR).Verification
proto/…/v1p1/asr.protoandtechmo-asr-api'sasr.protocompared (all messages, field names/numbers/types/labels, enums, rpc signatures): identical (78/78)livekit-agents==1.5.1:masterfails withVersionError; this branch imports OK (protobuf 6.33.6). Also OK when installed from the git URL of this branchasr_api.v1p1imports with protobuf 5.29.5, 6.33.6 and 7.36.2; 5.28.3 fails (hence>=5.29.0)from asr_api import v1p1raisesRuntimeError (... depends on grpcio>=1.70.0); 1.70.0 imports OKuv build): only plugin sources;Requires-Distas abovesession_id): transcripts OK. The responses frommasterand from this branch are the same, field by fieldKnown issues, not changed here
SUCCESSfinal with text followed by an emptyNO_INPUT_TIMEOUTfinal._recognize_imploverwrites the result with each final, so the last, empty one wins; the proto says clients should buffer an alternative from every final. Separate fix.techmo-asr-apiinstallsgoogle/rpc/status_pb2.py, the same path asgoogleapis-common-protos(pulled in by livekit-agents through the OTLP exporter), so the two packages overwrite each other's file. To be fixed inasr-api-python.techmo-asr-apiis published there.🤖 Generated with Claude Code